package com.springcloud.travel.line.controller;

import com.springcloud.travel.entity.Line;
import com.springcloud.travel.line.service.LineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * @author fyb
 * @version 1.0
 * @date 2021/3/25 10:31
 */
@RestController
@RequestMapping("/line")
public class LineController {
    @Autowired
    private LineService lineService;
    /**
     * @Author fyb
     * @Description //TODO 新增 路线
     * @Date 10:37 2021/3/25
     * @param line
     * @return java.lang.Boolean
     **/
    @PostMapping("/addLine")
    public Boolean addLine(@RequestBody Line line) {
        try {
            boolean insert = lineService.insert(line);
            return insert;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
    /**
     * @Author fyb
     * @Description //TODO  修改路线
     * @Date 10:37 2021/3/25
     * @param line
     * @return java.lang.Boolean
     **/
    @PostMapping("/updateLine")
    public Boolean updateLine(@RequestBody Line line) {
        try {
            boolean insert = lineService.updateById(line);
            return insert;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
    /**
     * @Author fyb
     * @Description //TODO 删除路线
     * @Date 10:37 2021/3/25
     * @param ids
     * @return java.lang.Boolean
     **/
    @PostMapping("/delLine")
    public Boolean delLine(@RequestParam("ids")String[] ids) {
        try {
            boolean insert = lineService.deleteBatchIds(Arrays.asList(ids));
            return insert;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

}
